<?php 
//$start_date = $this->session->userdata('start_date');
//$reason = $this->session->userdata('reason');
//print_r($edit);
//echo $edit['start_date'];
?>

<span><?php if($this->session->flashdata('leave_message')) {
echo '<div id="alert" class="alert alert-success"> ';
echo '<button type="button" class="close" data-dismiss="alert">&times;</button>';
echo ''.$this->session->flashdata('leave_message').'';
echo'</div>';
}?></span>
<h3>Apply For Leave</h3>
<div class="row-fluid">
<div class="span9">

<?php echo form_open('user/leave/apply_leave'); ?>

<table width="100%">
  <tr>
    <td>Start Date:</td> 
    <td><input type="text" name="start_date" class="datepicker" value="<?= isset($edit['start_date']) ? $edit['start_date'] : set_value('start_date'); ?>"/>
      <br />
      <?= form_error('start_date');?>
    </td>
    </tr>
  <tr>
    <td>Reason</td>
    <td><textarea class="span10" name="reason"><?= isset($edit['reason']) ? $edit['reason'] : set_value('reason'); ?></textarea>
      <br />
      <?= form_error('reason');?>
    </td>
     </tr> 
  <tr>
    <td>&nbsp;</td>
    <td>
    <input type="hidden" value="<?= isset($edit['id']) ? $edit['id'] : set_value('edit_id'); ?>" name="edit_id" /> 
    <input type="submit" class="btn btn-info" value="<?= isset($edit['id']) ? 'Update Leave' : 'Apply Leave' ?>" />
      <input type="reset" value="Reset Fields" class="btn btn-warning" />
    </td>
    </tr>
</table>
</form>
<hr />
<div>
<h5 class="text-info">Current Leave Status</h5>
<table class="table table-condensed" width="100%">
<tr class="success">
<td width="10%">Date</td>
<td width="30%">Reason</td>
<td width="5%">Status</td>
<td width="5%">Action</td>
</tr>
<?php 
foreach($pending_leaves as $row)
{
?>
<tr>
<td><?= $row->leave_date?></td>
<td><?= $row->reason?></td>
<td><?php
if($row->status == 'pending')
{
echo '<span class="text-error">'.$row->status.'</span>';	
}
else
{
	echo '<span class="text-success">'.$row->status.'</span>';	
}
 ?></td>
<td>
<a href="<?= site_url('user/leave/edit').'/'.$row->id;?>" rel="tooltip" title="Edit Leave"><i class="icon-pencil"></i></a>
&nbsp;&nbsp;&nbsp;<a onclick="return confirm('Are you sure you want to Delete this Leave??? Press [Cancel] not to delete.')" href="<?= site_url('user/leave/delete').'/'.$row->id;?>" title="Delete Leave"><i class="icon-trash"></i></a>
</td>
</tr>
<?php }?>
</table>
</div>

<div>
<h5 class="text-info">Previous Leave Status</h5>
<table class="table table-condensed" width="100%">
<tr class="info">
<td>Start Date</td>
<td>Reason</td>
<td>Status</td>
</tr>

<tr>
<?php 
foreach($leave_status as $leave_stat)
{
?>
<tr>
<td><?= $leave_stat->leave_date?></td>
<td><?= $leave_stat->reason?></td>
<td><?php
if($leave_stat->status == 'pending')
{
echo '<span class="text-error">'.$leave_stat->status.'</span>';	
}
else
{
	echo '<span class="text-success">'.$leave_stat->status.'</span>';	
}
 ?></td>
</tr>
<?php }?>
</table>
</div>

</div>
<div class="span3">
<header>Overall Holiday Status</header>
<strong>Total Leave allocated : 12</strong>
<br />
<strong>Total Leave Granted : <?= $leave_granted;?> </strong>
<br />
<hr />
<strong>Total Leave Remaining : <?= $leave_remaning?></strong>
</div>
</div>



